using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ImageUpload;

namespace GM {
	/// <summary>
	/// Summary description for Resize.
	/// </summary>
	public class ResizeForm : System.Windows.Forms.Form {
		private System.Windows.Forms.Button btnResize;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.TextBox tbThumbPrefix;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private ResizeSettingsControl rsc;
		private System.Windows.Forms.GroupBox gbName;
		private System.Windows.Forms.RadioButton rbNameLeave;
		private System.Windows.Forms.RadioButton rbNameNumeric;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnAdvanced;

		public ResizeForm() {
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			SetSettings();

		}

		private void SetSettings(){
			string prefix = tbThumbPrefix.Text.Trim();
			
			if (FormGM.SelectedAccount == null) {
                FormGM.SelectedAccount = new Account();
                FormGM.SelectedAccount.Id = Guid.NewGuid();
			}

            FormGM.SelectedAccount.Url = "Local Resize";
            FormGM.SelectedAccount.ThumbPrefix = (prefix.Length == 0) ? "thumb_" : prefix;
            FormGM.SelectedAccount.ImageWidth = rsc.BigWidth;
            FormGM.SelectedAccount.ImageHeight = rsc.BigHeight;
            FormGM.SelectedAccount.ThumbHeight = rsc.ThumbHeight;
            FormGM.SelectedAccount.ThumbWidth = rsc.ThumbWidth;
            FormGM.SelectedAccount.JpegQuality = rsc.JpegQuality;
            //FormGM.SelectedAccount.NeedBig = rsc.NeedBig;
            //FormGM.SelectedAccount.NeedThumb = rsc.NeedThumb;
            //FormGM.SelectedAccount.RenameMethod = /*rbNameLeave.Checked ? ResizeSettings.RENAMEMETHODLEAVE :*/ ResizeSettings.RENAMEMETHODNUMERIC;
		}
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing ) {
			if( disposing ) {
				if(components != null) {
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent() {
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ResizeForm));
			this.rsc = new ResizeSettingsControl();
			this.btnResize = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.tbThumbPrefix = new System.Windows.Forms.TextBox();
			this.gbName = new System.Windows.Forms.GroupBox();
			this.rbNameNumeric = new System.Windows.Forms.RadioButton();
			this.rbNameLeave = new System.Windows.Forms.RadioButton();
			this.label1 = new System.Windows.Forms.Label();
			this.btnAdvanced = new System.Windows.Forms.Button();
			this.gbName.SuspendLayout();
			this.SuspendLayout();
			// 
			// rsc
			// 
			this.rsc.BigHeight = 600;
			this.rsc.BigWidth = 800;
			this.rsc.JpegQuality = 75;
			this.rsc.Location = new System.Drawing.Point(0, 0);
			this.rsc.Name = "rsc";
			this.rsc.Size = new System.Drawing.Size(296, 136);
			this.rsc.TabIndex = 0;
			this.rsc.ThumbHeight = 120;
			this.rsc.ThumbWidth = 160;
			// 
			// btnResize
			// 
			this.btnResize.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btnResize.Location = new System.Drawing.Point(96, 216);
			this.btnResize.Name = "btnResize";
			this.btnResize.TabIndex = 1;
			this.btnResize.Text = "Resize";
			this.btnResize.Click += new System.EventHandler(this.btnResize_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(184, 216);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 2;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// tbThumbPrefix
			// 
			this.tbThumbPrefix.Location = new System.Drawing.Point(120, 40);
			this.tbThumbPrefix.Name = "tbThumbPrefix";
			this.tbThumbPrefix.Size = new System.Drawing.Size(144, 20);
			this.tbThumbPrefix.TabIndex = 3;
			this.tbThumbPrefix.Text = "thumb_";
			// 
			// gbName
			// 
			this.gbName.Controls.Add(this.rbNameNumeric);
			this.gbName.Controls.Add(this.rbNameLeave);
			this.gbName.Controls.Add(this.tbThumbPrefix);
			this.gbName.Controls.Add(this.label1);
			this.gbName.Location = new System.Drawing.Point(8, 136);
			this.gbName.Name = "gbName";
			this.gbName.Size = new System.Drawing.Size(280, 72);
			this.gbName.TabIndex = 4;
			this.gbName.TabStop = false;
			this.gbName.Text = "Filename";
			// 
			// rbNameNumeric
			// 
			this.rbNameNumeric.Location = new System.Drawing.Point(8, 40);
			this.rbNameNumeric.Name = "rbNameNumeric";
			this.rbNameNumeric.TabIndex = 1;
			this.rbNameNumeric.Text = "set numeric";
			// 
			// rbNameLeave
			// 
			this.rbNameLeave.Checked = true;
			this.rbNameLeave.Location = new System.Drawing.Point(8, 16);
			this.rbNameLeave.Name = "rbNameLeave";
			this.rbNameLeave.TabIndex = 0;
			this.rbNameLeave.TabStop = true;
			this.rbNameLeave.Text = "leave original";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(120, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 16);
			this.label1.TabIndex = 5;
			this.label1.Text = "Thumb prefix";
			// 
			// btnAdvanced
			// 
			this.btnAdvanced.Location = new System.Drawing.Point(8, 216);
			this.btnAdvanced.Name = "btnAdvanced";
			this.btnAdvanced.TabIndex = 6;
			this.btnAdvanced.Text = "Advanced";
			this.btnAdvanced.Click += new System.EventHandler(this.btnAdvanced_Click);
			// 
			// ResizeForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(296, 248);
			this.Controls.Add(this.btnAdvanced);
			this.Controls.Add(this.gbName);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnResize);
			this.Controls.Add(this.rsc);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.Name = "ResizeForm";
			this.Text = "Resize";
			this.gbName.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnCancel_Click(object sender, System.EventArgs e) {
			this.Close();
		}

		private void btnResize_Click(object sender, System.EventArgs e) {
			SetSettings();
		}

		private void btnAdvanced_Click(object sender, System.EventArgs e) {
			ResizeMethodForm resizeMethodForm = new ResizeMethodForm();
			if (resizeMethodForm.ShowDialog() == DialogResult.OK) {

			}
		}

	}
}
